<!DOCTYPE HTML><html>
<head>
<? echo $h->meta($title, $kwd, $dpn); ?>
<? require_once("lib.php"); ?>
<script src="<?=$ecom?>/js/jquery.validate.js" type="text/javascript"></script>
<script src="<?=$ecom?>/js/jquery.metadata.js" type="text/javascript"></script>
</head>
<body>
<? include_once("header.php"); ?>
<div id="wrap">
<div class="breadcrumb">
    <a href="./"><?=WEB_INDEX_PAGE?></a> &gt; <a href="member.html"><?=WEB_MEMBER_CENTER?></a> &gt; <span><?=$cate_name?></span>
</div><!--breadcrumb end-->
<div id="" class="w180 left">
    <? require 'member_menu.php' ?>
</div><!--. w220-->
<div id="" class="right w760">
    <div class="">
        <div class="h2news">
            <h2><?=$cate_name?></h2>
        </div>

        <?
        $str=''; $k=0;
        if($do=='update'){?>
            <div class="address_b">
                <div class="address_title">
                    <div class="right"></div>
                    <div clss="left"><strong><?=WEB_ORDER_EDIT_MY_SALES_SERVICE?></strong></div>
                    <div class="clear"></div>
                </div>
                <div class="address_box">
                    <form method="post" class="need_check">
                        <input type="hidden" name="action" value="update" />
                        <input type="hidden" name="temid" value="<?=$id?>" />
                        <input type="hidden" name="refer" value="<?=$refer?>" />
                        <table width="100%">
                            <tr><td width="120" class="tright"><?=WEB_ORDER_SERVICE_CATETYPE?>:</td><td>
                                    <?
                                    foreach($service_type as $val){
                                        if($info['service_type'] == $val['id']){
                                            echo $val['name_'.$lang];
                                        }
                                    }
                                    ?>
                            </td></tr>
                            <tr><td width="120" class="tright"><?=WEB_ORDER_ADD_SALES_ORDER?>:</td><td><a href="old_order.php?code=<?=$detail_info['sales_order_id']?>"><?=$detail_info['sales_order_id']?></a></td></tr>
                            <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_NAME?>:</td><td><a href="product-<?=$detail_info['p_id']?>.html"><?=$detail_info['product_name']?></a></td></tr>
                            <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_QUANTITY?>:</td><td><input name="quantity" value="<?=$info['quantity']?>" type="text" class="g {validate:{required:true,messages:{required:'<?=WEB_ORDER_ADD_SALES_PERSON_REQUIRED?>'}}}" type="text"/></td></tr>
                            <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_PERSON?>:</td><td><input name="contact_name" value="<?=$info['contact_name']?>" class="g {validate:{required:true,messages:{required:'<?=WEB_ORDER_ADD_SALES_PERSON_REQUIRED?>'}}}" type="text"/></td></tr>
                            <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_PHONE?>:</td><td><input name="phone" value="<?=$info['phone']?>" class="g {validate:{required:true,messages:{required:'<?=WEB_ORDER_ADD_SALES_PHONE_REQUIRED?>'}}}" type="text" /></td></tr>
                            <?if(!$detail_info['is_virtual']){?>
                                <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_ADDRESS?>:</td><td><input name="address" value="<?=$info['address']?>" class="g {validate:{required:true,messages:{required:'<?=WEB_ORDER_ADD_SALES_PHONE_REQUIRED?>'}}}" type="text" /></td></tr>
                                <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_ZIP?>:</td><td><input name="zip" value="<?=$info['zip']?>" class="g {validate:{required:true,messages:{required:'<?=WEB_ORDER_ADD_SALES_PHONE_REQUIRED?>'}}}" type="text" /></td></tr>
                            <?}?>
                            <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_OTHER?>:</td><td><?echo $h->select('contact_type', $info['contact_type'], $contact_type, 'id', 'name_'.$lang, 'g')?>&nbsp;&nbsp;<input name="contact_other" value="<?=$info['contact_other']?>" class="g" style="width: 27%"/></td></tr>
                            <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_REASON?>:</td><td>
                                <script type="text/javascript">
                                    $(function(){
                                        <?if($info['refund_status'] != 1){?>
                                            $('input').attr('disabled', 'true');
                                            $('select').attr('disabled', 'true');
                                        <?}?>
                                        <?if($info['refund_reason_id'] == 0){?>
                                            $('.reason_other').removeClass('hide');
                                        <?}?>
                                        $('select[name="refund_reason_id"]').on('change', function(){
                                            if($(this).val() == 0){
                                                $('.reason_other').removeClass('hide');
                                                $('input[name="refund_remark"]').addClass("{validate:{required:true,message:{required:'<?=WEB_ORDER_ADD_SALES_REASON_REQURED?>'}}}");
                                            }else{
                                                $('input[name="refund_remark"]').removeClass("{validate:{required:true,message:{required:'<?=WEB_ORDER_ADD_SALES_REASON_REQURED?>'}}}");
                                                $('.reason_other').addClass('hide');
                                            }
                                        });
                                    });
                                </script>
                                <select name="refund_reason_id" class="g">
                                    <?foreach($refund as $key => $val){
                                        ?>
                                        <option value="<?=$val['id']?>" <?if($info['refund_reason_id']==$val['id']) echo 'selected';?>><?=$val['name_'.$lang]?></option>
                                    <?
                                    }?>
                                    <option value="0" <?if($info['refund_reason_id'] == 0) echo 'selected';?>><?=WEB_ORDER_CANCEL_OTHER_REASON?></option>
                                </select>
                            </td></tr>
                        <tr class="hide reason_other"><td></td><td><input name="refund_remark" value="<?=$info['refund_remark']?>" class="g" /></td></tr>
                        <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_DESCRIPTION?>:</td><td><input name="description" value="<?=$info['description']?>" class="g" /></td></tr>
                        <tr><td class="tright"><?=WEB_BANK_RECEIPT?>:</td><td>
                                <? if($info['pic'] != ''){ ?>
                                    <a href="upload/<?=$info['pic']?>" target="_blank"><img src="upload/<?=$info['pic']?>" height="120" /></a><br />
                                <? } ?>
                                <? echo $h->cfile('pic', 'g');
                                //if($not_first_time==1) $receipt_button=' '.WEB_UPDATE.' ';
                                ?></td></tr>
                            <tr><td>&nbsp;</td><td>
                                    <div class="px20"></div>
                                    <input type="submit" class="button_blue" valud="<?=WEB_UPDATE?>" /> &nbsp; <a href="<? echo $url.'.php'; ?>" class="orange"><?=WEB_CANCEL?></a></td></tr>
                        </table><div class="px20"></div>
                    </form>
                </div></div><!-- .addressb -->
        <?}
        else {
            if($detail_id){
        ?> <div class="address_a">
            <div class="px10" id="add"></div>
            <div class="address_title_a">
                <div class="right"></div>
                <div clss="left"><strong class="gray"><?=WEB_ORDER_ADD_MY_SALES_SERVICE?></strong></div>
                <div class="clear"></div>
            </div>
            <div class="address_box">
                <form method="post" class="need_check" enctype="multipart/form-data">
                    <input type="hidden" name="action" value="insert" />
                    <table width="100%">
                        <?$detail_info = product_detail($detail_id);
                        $service_type = $code_array['service_type'];
//                        pre($service_type);
                        ?>
                        <tr><td width="120" class="tright"><?=WEB_ORDER_SERVICE_CATETYPE?>:</td><td>
                                <?
                                $str_radio = '';
                                $i=1;
                                $order_info = $order_service->get_rows(1024,'sales_detail_id', $detail_id);
                                $service_type_info = array();
                                foreach($order_info as $val){
                                    $service_type_info[] = $val['service_type'];
                                }
                                foreach($service_type as $val){
                                    $class = '';
                                    if(!in_array($val['id'], $service_type_info) || $val['id']==3){
                                        if($i){
                                            $class="{validate:{required:true,messages:{required:'".WEB_ORDER_ADD_SALES_ORDER_TYPE."'}}}";
                                            $i=0;
                                        }
                                        $str_radio .= '<input type="radio" name="service_type" class="'.$class.'" value="'.$val['id'].'"/>'.$val['name_'.$lang].'&nbsp;';
                                    }
                                }
                                echo $str_radio;
                                ?>
                                </td></tr>
                        <tr><td width="120" class="tright"><?=WEB_ORDER_ADD_SALES_ORDER?>:</td><td><input type="hidden" name="sales_detail_id" value="<?=$detail_id?>"/><input name="sales_order_id" value="<?=$detail_info['order_id']?>" type="hidden" /><a href="old_order.php?code=<?=$detail_info['sales_order_id']?>"><?=$detail_info['sales_order_id']?></a></td></tr>
                        <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_NAME?>:</td><td><input name="p_id" type="hidden" value="<?=$detail_info['p_id']?>"/><input type="hidden" name="v_id" value="<?=$detail_info['v_id']?>"/><a href="product-<?=$detail_info['p_id']?>.html"><?=$detail_info['product_name']?></a></td></tr>
                        <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_QUANTITY?>:</td><td><input name="quantity" value="1" type="text" class="g {validate:{required:true,messages:{required:'<?=WEB_ORDER_ADD_SALES_PERSON_REQUIRED?>'}}}" type="text"/></td></tr>
                        <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_PERSON?>:</td><td><input name="contact_name" value="<?=$detail_info['contact_name']?>" class="g {validate:{required:true,messages:{required:'<?=WEB_ORDER_ADD_SALES_PERSON_REQUIRED?>'}}}" type="text"/></td></tr>
                        <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_PHONE?>:</td><td><input name="phone" value="<?=$detail_info['phone']?>" class="g {validate:{required:true,messages:{required:'<?=WEB_ORDER_ADD_SALES_PHONE_REQUIRED?>'}}}" type="text" /></td></tr>
                        <?if(!$detail_info['is_virtual']){?>
                        <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_ADDRESS?>:</td><td><input name="address" value="<?=$detail_info['address']?>" class="g {validate:{required:true,messages:{required:'<?=WEB_ORDER_ADD_SALES_PHONE_REQUIRED?>'}}}" type="text" /></td></tr>
                        <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_ZIP?>:</td><td><input name="zip" value="<?=$detail_info['zip']?>" class="g {validate:{required:true,messages:{required:'<?=WEB_ORDER_ADD_SALES_PHONE_REQUIRED?>'}}}" type="text" /></td></tr>
                        <?}?>
                        <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_OTHER?>:</td><td><?echo $h->select('contact_type', 0, $contact_type, 'id', 'name_'.$lang, 'g')?>&nbsp;&nbsp;<input name="contact_other" value="" class="g" style="width: 27%" type="text"/></td></tr>
                        <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_REASON?>:</td><td>
                                <script type="text/javascript">
                                    $(function(){
                                        $('select[name="refund_reason_id"]').on('change', function(){
                                            if($(this).val() == 0){
                                                $('.reason_other').removeClass('hide');
                                                $('input[name="refund_remark"]').addClass("{validate:{required:true,message:{required:'<?=WEB_ORDER_ADD_SALES_REASON_REQURED?>'}}}");
                                            }else{
                                                $('input[name="refund_remark"]').removeClass("{validate:{required:true,message:{required:'<?=WEB_ORDER_ADD_SALES_REASON_REQURED?>'}}}");
                                                $('.reason_other').addClass('hide');
                                            }
                                        });
                                    });
                                </script>
                                <select name="refund_reason_id" class="g">
                                    <?foreach($refund as $key => $val){
                                        ?>
                                        <option value="<?=$val['id']?>"><?=$val['name_'.$lang]?></option>
                                    <?
                                    }?>
                                    <option value="0"><?=WEB_ORDER_CANCEL_OTHER_REASON?></option>
                                </select>
                            </td></tr>
                        <tr class="hide reason_other"><td></td><td><input name="refund_remark" value="" class="g" /></td></tr>
                        <tr><td class="tright"><?=WEB_ORDER_ADD_SALES_DESCRIPTION?>:</td><td><input name="description" value="" class="g" type="text" /></td></tr>
                        <tr><td class="tright"><?=WEB_BANK_RECEIPT?>:</td><td>
                                <? if(isset($info['pic']) && $info['pic'] != ''){ ?>
                                    <a href="upload/<?=$info['pic']?>" target="_blank"><img src="upload/<?=$info['pic']?>" height="120" /></a><br />
                                <? } ?>
                                <? echo $h->cfile('pic', 'g');
                                //if($not_first_time==1) $receipt_button=' '.WEB_UPDATE.' ';
                                ?></td></tr>
                        <tr><td>&nbsp;</td><td>
                                <div class="px20"></div>
                                <input type="submit" class="button_blue" value="<?=WEB_ADD?>" /></td></tr>
                    </table><div class="px20"></div>
                </form>
            </div>
        </div><!-- .addressb -->
                <?}else{?>
            <div class="address_title_a">
                <div class="right"></div>
                <div clss="left"><strong class="gray"><?=WEB_ORDER_MY_SALES_SERVICE?></strong></div>
                <div class="clear"></div>
            </div>
            <?
        foreach($info as $val){
            $temid=$val['id'];
            $refund_reason = '';
            if($val['refund_reason_id'] == 0){
                $refund_reason = $val['refund_remark'];
            }else{
                foreach($refund as $r_key => $r_val){
                    if($val['refund_reason_id'] == $r_val['id']){
                        $refund_reason = $r_val['name_'.$lang];
                    }
                }
            }
            $pic = '';
            if(!empty($val['pic'])){
                $pic = '<img src="upload/'.$val['pic'].'" height="120" />';
            }

            $refund_status = '';
            if(!empty($val['refund_status'])){
                $refund_status = $refund_arr[$val['refund_status']]['name_'.$lang];
            }
            $detail_info = product_detail($val['sales_detail_id']);

            $str.='<div class="address_b delete'.$temid.'">
				<div class="address_title">
					<div class="right"><a href="'.$url.'.php?do=update&id='.$temid.'" class="blue">'.WEB_EDIT.'</a> &nbsp;</div>
					<div clss="left">';
//            $str.='<div class="address_b delete'.$temid.'">
//				<div class="address_title">
//					<div class="right"><a href="'.$url.'.php?do=update&id='.$temid.'" class="blue">'.WEB_EDIT.'</a> &nbsp; <a onclick="ajax_delete(\'order_service\',\''.$temid.'\')" class="blue">'.WEB_DELETE.'</a></div>
//					<div clss="left">';
            $str.='<strong>'.$code_array['service_type'][$val['service_type']]['name_'.$lang].'&nbsp;---&nbsp;'.$refund_status.'</strong>';
            $str.='</label></div>
					<div class="clear"></div>
				</div>
					<div class="address_box">
						<table width="100%">
							<tr><td width="120" class="tright">'.WEB_ORDER_ADD_SALES_ORDER.':</td><td><a href="old_order.php?code='.$detail_info['sales_order_id'].'">'.$detail_info['sales_order_id'].'</a></td><td rowspan="4" align="center">'.$pic.'</td></tr>
							<tr><td class="tright">'.WEB_ORDER_ADD_SALES_NAME.':</td><td><a href="product-'.$detail_info['p_id'].'.html">'.$detail_info['product_name'].'</a></td></tr>
							<tr><td class="tright">'.WEB_ORDER_ADD_SALES_REASON.':</td><td>'.$refund_reason.'</td></tr>
							<tr><td class="tright">'.WEB_ORDER_ADD_SALES_DESCRIPTION.':</td><td>'.$val['description'].'</td></tr>
						</table>
					</div></div><!-- .addressb -->';
            $k++;
        }
        echo $str;
        ?>
        <? }?>
        <div class="clear"></div>
    </div><!--.-->
    <?}?>
</div><!--# featured_and_ad_right-->
<div class="clear"></div>
<div class="px20"></div>
<div class="clear"></div>
</div>
<? include("footer.php"); ?>
<script type="text/javascript">
    $(document).ready(function(){
        $(".need_check").validate({meta: "validate", onkeyup: false,
            errorPlacement: function( label, element ) {
                element.parent().append("<br>").append(label);
            }
        });
    });
</script>
</body>
</html>
